package com.yenlien.traceyun.control.service.rest;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.control.bean.RestURL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-06-08
 * @description:
 **/
@Service
public class ResourceRestService {


    @Autowired
    private RestService restService;


    /**
     * 加载App功能
     *
     * @return
     */
    public JSONObject findByAppId(String appId) {
        return restService.getJson(RestURL.USERCENTER + "resource/findByAppId/" + appId);
    }

    /**
     * 加载App功能
     *
     * @return
     */
    public JSONObject findByCustomAppVersion(String customAppVersionId) {
        return restService.getJson(RestURL.USERCENTER + "resource/findCustomAppVersion/" + customAppVersionId);
    }

    /**
     * 加载用户
     *
     * @return
     */
    public JSONObject loadAllAppMenu(String userId) {
        return restService.getJson(RestURL.USERCENTER + "resource/load/user/appmenus/" + userId);
    }

    /**
     * 加载企业对应的资源
     *
     * @param companyId
     * @return
     */
    public JSONObject loadAllCompanyAppMenu(String companyId) {
        return restService.getJson(RestURL.USERCENTER + "resource/load/company/appmenus/" + companyId);
    }

    /**
     * set
     *
     * @return
     */
    public JSONObject setCompanyAppMenu(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "resource/set/company/appmenus", jsonObject);
    }

    public JSONObject save(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "resource/save", jsonObject);
    }

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    public JSONObject dele(String id) {
        return restService.getJson(RestURL.USERCENTER + "resource/dele/" + id);
    }
}
